package pers.jason.wppm.auth.api;

import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import pers.jason.wppm.api.support.ResultView;
import pers.jason.wppm.api.support.ServiceName;

import java.util.Map;

/**
 * 对外提供feign接口
 */
@FeignClient(name = ServiceName.WPPM_AUTH_SERVICE)
public interface UserApi {

    /**
     * 用户认证请求获取用户信息
     * @param loginType
     * @param mobile
     * @param email
     * @param loginName
     * @return
     */
    @RequestMapping(value = "/user", method = RequestMethod.POST)
    ResultView getUserByLoginName(
            @RequestParam("loginType") String loginType,
            @RequestParam(value = "mobile", required = false, defaultValue = "") String mobile,
            @RequestParam(value = "email", required = false, defaultValue = "") String email,
            @RequestParam(value = "loginName", required = false, defaultValue = "") String loginName
    );

    /**
     * 手机号注册用户
     * @param params
     * @return
     */
    @RequestMapping(value = "user/user", method = RequestMethod.POST)
    ResultView registWithMobile(Map<String, Object> params);

    /**
     * 软删除用户
     * @param id
     * @return
     */
    @RequestMapping(value = "user/{id}", method = RequestMethod.DELETE)
    ResultView deleteUser(@PathVariable("id") String id);

    /**
     * 修改用户基本信息
     * @param params
     * @return
     */
    @RequestMapping(value = "user", method = RequestMethod.PUT)
    ResultView updateUserInfo(Map<String, Object> params);

    /**
     * 条件查询用户列表
     * @param params
     * @return
     */
    @RequestMapping(value = "user/list", method = RequestMethod.GET)
    ResultView queryUserList(Map<String, Object> params);

    /**
     * 根据id获取用户所有信息
     * @param id
     * @return
     */
    @RequestMapping(value = "user/{id}", method = RequestMethod.GET)
    ResultView getUserInfoById(@PathVariable("id") String id);

}
